<<<<<<< HEAD
"""
插值方法：测量高程
"""

import numpy as np
from scipy import interpolate
from mpl_toolkits.mplot3d import Axes3D
import matplotlib as mpl
import matplotlib.cm as cm
import matplotlib.pyplot as plt

plt.style.use(['science', 'grid', 'muted'])

x0 = np.array([129, 140, 103.5, 88, 185.5, 195, 105,
               157.5, 107.5, 77, 81, 162, 162, 117.5])
y0 = np.array([7.5, 141.5, 23, 147, 22.5, 137.5, 85.5,
               -6.5, -81, 3, 56.5, -66.5, 84, -33.5])
z0 = np.array([4, 8, 6, 8, 6, 8, 8, 9, 9, 8, 8, 9, 4, 9]*14).reshape((14, 14))
x0, y0 = np.meshgrid(x0, y0)
# 三次样条二维插值
f = interpolate.interp2d(x0, y0, z0, kind='linear')
x1 = np.linspace(x0.min(), x0.max(), 100)
y1 = np.linspace(y0.min(), y0.max(), 100)
z1 = f(x1, y1)
x1, y1 = np.meshgrid(x1, y1)

plt.figure()

ax0 = plt.subplot(1, 2, 1, projection='3d')
surf0 = ax0.plot_surface(x0, y0, z0, rstride=2, cstride=2,
                         cmap=cm.coolwarm, linewidth=0.5, antialiased=True)
ax0.set_xlabel('x0')
ax0.set_ylabel('y0')
ax0.set_zlabel('z0')
plt.colorbar(surf0, shrink=0.5, aspect=5)

ax1 = plt.subplot(1, 2, 2, projection='3d')
surf1 = ax1.plot_surface(x1, y1, z1, rstride=2, cstride=2,
                         cmap=cm.coolwarm, linewidth=0.5, antialiased=True)
ax1.set_xlabel('x1')
ax1.set_ylabel('y1')
ax1.set_zlabel('z1')
plt.colorbar(surf1, shrink=0.5, aspect=5)

plt.suptitle('Interpolation-2D(The bottom: {:3f})'.format(np.min(z1)))
plt.show()
=======
"""
插值方法：测量高程
"""

import numpy as np
from scipy import interpolate
from mpl_toolkits.mplot3d import Axes3D
import matplotlib as mpl
import matplotlib.cm as cm
import matplotlib.pyplot as plt

plt.style.use(['science', 'grid', 'muted'])

x0 = np.array([129, 140, 103.5, 88, 185.5, 195, 105,
               157.5, 107.5, 77, 81, 162, 162, 117.5])
y0 = np.array([7.5, 141.5, 23, 147, 22.5, 137.5, 85.5,
               -6.5, -81, 3, 56.5, -66.5, 84, -33.5])
z0 = np.array([4, 8, 6, 8, 6, 8, 8, 9, 9, 8, 8, 9, 4, 9]*14).reshape((14, 14))
x0, y0 = np.meshgrid(x0, y0)
# 三次样条二维插值
f = interpolate.interp2d(x0, y0, z0, kind='linear')
x1 = np.linspace(x0.min(), x0.max(), 100)
y1 = np.linspace(y0.min(), y0.max(), 100)
z1 = f(x1, y1)
x1, y1 = np.meshgrid(x1, y1)

plt.figure()

ax0 = plt.subplot(1, 2, 1, projection='3d')
surf0 = ax0.plot_surface(x0, y0, z0, rstride=2, cstride=2,
                         cmap=cm.coolwarm, linewidth=0.5, antialiased=True)
ax0.set_xlabel('x0')
ax0.set_ylabel('y0')
ax0.set_zlabel('z0')
plt.colorbar(surf0, shrink=0.5, aspect=5)

ax1 = plt.subplot(1, 2, 2, projection='3d')
surf1 = ax1.plot_surface(x1, y1, z1, rstride=2, cstride=2,
                         cmap=cm.coolwarm, linewidth=0.5, antialiased=True)
ax1.set_xlabel('x1')
ax1.set_ylabel('y1')
ax1.set_zlabel('z1')
plt.colorbar(surf1, shrink=0.5, aspect=5)

plt.suptitle('Interpolation-2D(The bottom: {:3f})'.format(np.min(z1)))
plt.show()
>>>>>>> a66c8eec2c3bbe955d7da215f43ffffda9c7b6b5
